package com.bjsxt.comment.controller;

import com.bjsxt.comment.service.CommentService;
import com.livegoods.commons.vo.LivegoodsResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName : CommentController
 * @Description :
 * @Author : ZWZ
 * @Date: 2021/8/26 10:43
 */
@RestController
@CrossOrigin
public class CommentController {

    @Autowired
    private CommentService commentService;

    /**
     * 获取商品评论信息
     *
     * @param itemId
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/comment")
    public LivegoodsResult findCommentByItemId(@RequestParam(value = "id") String itemId, int page,
                                               @RequestParam(defaultValue = "5") int size) {
        return commentService.findCommentByItemId(itemId, page, size);
    }

    /**
     * 新增评论
     *
     * @param orderId
     * @param comment
     * @return
     */
    @PostMapping("/feelback")
    public LivegoodsResult feelback(String orderId,
                                    @RequestParam(name = "feelback") String comment) {
        return commentService.feelback(orderId, comment);
    }

}
